package org.flh.book.shop.dao;

import java.util.List;
import org.flh.book.shop.entity.Book;
import org.flh.book.shop.mapper.BookMapper;
import org.flh.book.shop.utils.Page;
import org.flh.book.shop.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 描述：
 *
 * @author 花好月圆
 * @date 2021/1/15 14:03
 */
@Repository
public class BookDaoImpl implements BookDao {

    @Autowired
    private BookMapper mapper;

    @Override
    public int addBook(Book book) {
        return mapper.addBook(book);
    }

    @Override
    public List<Book> queryCondition(String name, String author,
        Page page) {
        return mapper.queryCondition(name, author, PageUtils.getRowStart(page), PageUtils.getRowEnd(page));
    }

    @Override
    public int queryTotal(String name, String author) {
        return mapper.queryTotal(name, author);
    }

    @Override
    public void updateBook(Book book) {
        mapper.updateBook(book);
    }

    @Override
    public void deleteById(int id) {
        mapper.deleteById(id);
    }

    @Override
    public void batchDelete(List<Integer> idList) {
        mapper.batchDelete(idList);
    }
}
